package com.zahb.qadx.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding

/**
 * Created by Zdw on 2021/07/05 11:46
 */
abstract class BaseFragmentV2 : BaseFragmentExt() {

    private var _binding: ViewBinding? = null

    override fun getLayout(): Int {
        return 0
    }

    abstract fun initViewBinding(inflater: LayoutInflater, container: ViewGroup?): ViewBinding?

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        _binding = initViewBinding(inflater, container)
        return if (_binding == null) {
            mRootView = null
            null
        } else {
            mRootView = _binding!!.root
            initViews(mRootView)
            mRootView
        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}